﻿using BaseUi.ViewModel;
using HandyControl.Controls;
using Ping9719.WpfEx;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;

namespace BaseUi
{
    /// <summary>
    /// 主页
    /// </summary>
    public partial class HomeView : UserControlBase
    {
        /// <summary>
        /// 灰色
        /// </summary>
        public SolidColorBrush radiocolor1 = new SolidColorBrush(Color.FromRgb(220, 220, 220));
        /// <summary>
        /// 亮绿色
        /// </summary>
        public SolidColorBrush radiocolor2 = new SolidColorBrush(Color.FromRgb(50, 205, 50));
        public static HomeViewModel viewModel = new HomeViewModel();

        public HomeView()
        {
            InitializeComponent();

            this.DataContext = viewModel;
        }

        private void loadFir(object sender, EventArgs e)
        {
            if (this.IsInDesignMode)
                return;


            viewModel.image1 = this.img1;
            viewModel.image2 = this.img2;
            viewModel.image3 = this.img3;
            viewModel.image4 = this.img4;
            viewModel.image1.StartListener(LocalFile.Config.img1);
            viewModel.image2.StartListener(LocalFile.Config.img2);
            viewModel.LoadTask();
        }

        private void RunStateButClick(object sender, RoutedEventArgs e)
        {
            viewModel.RunStateClick((RunStateButtonClick)e.OriginalSource);
        }

        

        

        private void annuyou(object sender, RoutedEventArgs e)
        {
            if (viewModel.RunState != RunState.Stop)
            {
                Growl.Info("非停止状态禁止改变产品类型");
                viewModel.AddTempTextErr("产品类型", new string[] { "非停止状态禁止改变产品类型" + DateTime.Now.ToString() });
                radioButton1.IsChecked = viewModel.butthave;
                radioButton2.IsChecked = viewModel.buttno;
            }
            else 
            {
                viewModel.butthave = true;
                viewModel.buttno = false;
                radioButton1.Background = radiocolor2;
                radioButton2.Background = radiocolor1;
            }
        }

        private void annuwu(object sender, RoutedEventArgs e)
        {if (viewModel.RunState != RunState.Stop)
            {
                Growl.Info("非停止状态禁止改变按钮选项");
                viewModel.AddTempTextErr("产品类型", new string[] { "非停止状态禁止改变产品类型" + DateTime.Now.ToString() });
                radioButton1.IsChecked = viewModel.butthave;
                radioButton2.IsChecked = viewModel.buttno;
            }
            else
            {
                viewModel.butthave = false;
                viewModel.buttno = true;
                radioButton1.Background = radiocolor1;
                radioButton2.Background = radiocolor2;
            }
        }
    }
}
